import { requestClient } from '#/api/request';

export namespace TMDBApi {
  /** Drama项 */
  export interface DramaItem {
    original: number;
    title: string;
    time: string;
    image: string;
    source: string;
    count: number;
  }

  /** 返回的Drama列表 */
  export interface dramaList {
    list: DramaItem[];
  }

  /** Drama查询参数 */
  export interface DramaSearch {
    dramaName?: string;
  }

  /** Drama详情查询参数 */
  export interface DramaDetailsSearch {
    id: any;
  }

  /** Season项 */
  export interface SeasonItem {
    sid: number;
    snumber: number;
    average: number;
    title: string;
    count: string;
    time: string;
    image: string;
    source: string;
  }

  /** 返回的Drama详情 */
  export interface DramaDetails {
    name?: string;
    overview?: string;
    seasonVoList?: SeasonItem[];
  }

  /** 资源预览参数 */
  export interface DramaResourcePreview {
    dramaName: string;
    dramaId: number;
    seasonId: number;
    cloudType: string;
    videoResolution: string;
    videoType: string;
    shareStatus: string;
    resourceLink: string;
    reConfig: string;
    resourceCode: string;
  }

  /** 分享资源预览参数 */
  export interface ShareResourcePreview {
    id: string;
  }

  /** Drama资源预览项 */
  export interface SeasonPreviewItem {
    tmdbName: string;
    dataSize: string;
    videoType: string;
    protoName: string;
    duration: string;
    videoResolution: string;
    videoFps: string;
    createdAt: string;
    seasonNum: number;
  }

  /** 返回的Drama资源预览详情 */
  export interface DramaPreview {
    passcode?: string;
    pwdId?: string;
    pdirFid?: string;
    stoken?: string;
    authorName?: string;
    authorType?: string;
    authorAvatar?: string;
    expiredAt?: string;
    fileDetailList?: SeasonPreviewItem[];
    status?: boolean;
    msg?: string;
    lastCount: number;
    lastName: string;
  }

  /** 保存Drama资源参数 */
  export interface DramaResourceShare {
    dramaName: string;
    dramaId: number;
    seasonId: number;
    seasonName: string;
    cloudType: string;
    videoResolution: string;
    videoType: string;
    shareStatus: string;
    resourceLink: string;
    reConfig: string;
    resourceCode: string;
    lastCount: number;
    lastName: string;
  }

  /** 查询Drama资源参数 */
  export interface DramaResourceSearchParam {
    dramaId: number;
    seasonId: number;
    pageNum: number;
    pageSize: number;
    cloudType: string;
    videoType: string;
    videoResolution: string;
  }

  /** 查询Drama资源子集 */
  export interface DramaResourceSearchItem {
    last_count: number;
    create_time: string;
    meShare: boolean;
    video_resolution: string;
    share_status: string;
    season_name: string;
    resource_code: string;
    last_name: string;
    season_id: number;
    video_type: string;
    re_config: string;
    update_time: string;
    cloud_type: string;
    resource_link: string;
    drama_name: string;
    user_id: number;
    nickname: string;
    id: string;
    drama_id: number;
    status: string;
    msg: string;
  }

  /** 查询Drama资源参数返回 */
  export interface DramaResourceSearch {
    total: number;
    pageSize: number;
    pageNum: number;
    data: DramaResourceSearchItem[];
  }
}

/**
 * 查询Drama列表
 */
export async function searchDramaListApi(data: TMDBApi.DramaSearch) {
  return requestClient.post<TMDBApi.dramaList>('/tmdb/drama/search', data);
}

/**
 * 查询Drama详情
 */
export async function searchDramaDetailsApi(data: TMDBApi.DramaDetailsSearch) {
  return requestClient.post<TMDBApi.DramaDetails>('/tmdb/drama/details', data);
}

/**
 * Drama资源预览
 */
export async function searchDramaPreviewApi(
  data: TMDBApi.DramaResourcePreview,
) {
  return requestClient.post<TMDBApi.DramaPreview>('/tmdb/drama/preview', data);
}

/**
 * Drama资源预览
 */
export async function searchSharePreviewApi(
  data: TMDBApi.ShareResourcePreview,
) {
  return requestClient.post<TMDBApi.DramaPreview>('/share/drama/preview', data);
}

/**
 * Drama资源删除
 */
export async function deleteSharePreviewApi(
  data: TMDBApi.ShareResourcePreview,
) {
  return requestClient.post<string>('/share/drama/delete', data);
}

/**
 * 保存Drama资源
 */
export async function saveDramaShareApi(data: TMDBApi.DramaResourceShare) {
  return requestClient.post<string>('/tmdb/drama/share', data);
}

/**
 * 查询Drama资源
 */
export async function searchDramaShareApi(
  data: TMDBApi.DramaResourceSearchParam,
) {
  return requestClient.post<TMDBApi.DramaResourceSearch>(
    '/tmdb/drama/list',
    data,
  );
}
